package by.grsu.coctails.db.tables;

import by.grsu.coctails.model.db.CoctailsCategoryDb;
import android.content.ContentValues;
import android.database.Cursor;

public class CoctailsCategoryTable {
	public static final String NAME = "CoctailCategory";

	private static final String[] COCTAIL_CATEGORY_COLUMNS = { "ID", "Name",
			"Description", "Image" };

	public static final int ID_COLUMN_INDEX = 0;

	public static final int NAME_COLUMN_INDEX = 1;

	public static final String NAME_COLUMN = COCTAIL_CATEGORY_COLUMNS[NAME_COLUMN_INDEX];

	public static final int DESCRIPTION_COLUMN_INDEX = 2;

	public static final String DESCRIPTION_COLUMN = COCTAIL_CATEGORY_COLUMNS[DESCRIPTION_COLUMN_INDEX];

	public static final int IMAGE_COLUMN_INDEX = 3;

	public static final String IMAGE_COLUMN = COCTAIL_CATEGORY_COLUMNS[IMAGE_COLUMN_INDEX];

	public static ContentValues getContentValues(
			CoctailsCategoryDb coctailCategory) {
		ContentValues contentValues = new ContentValues();
		contentValues.put(NAME_COLUMN, coctailCategory.getName());
		contentValues.put(DESCRIPTION_COLUMN, coctailCategory.getDescription());
		contentValues.put(IMAGE_COLUMN, coctailCategory.getImagePath());
		return contentValues;
	}

	public static CoctailsCategoryDb getCoctailCategory(Cursor cursor) {
		String name = cursor.getString(CoctailsCategoryTable.NAME_COLUMN_INDEX);
		String description = cursor
				.getString(CoctailsCategoryTable.DESCRIPTION_COLUMN_INDEX);
		String imagePath = cursor
				.getString(CoctailsCategoryTable.IMAGE_COLUMN_INDEX);
		int id = cursor.getInt(CoctailsCategoryTable.ID_COLUMN_INDEX);

		return new CoctailsCategoryDb(name, description, imagePath, id);
	}
}
